package com.vg.service;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;

import com.androidhive.jsonparsing.JSONParser;
import com.androidhive.jsonparsing.MyAdapter;
import com.vg.config.linkUrl;
import com.vg.spinner.Student;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class ServiceCity extends Service {
	String obj;
	MyAdapter adapter;
	JSONArray contacts;
	linkUrl mLinkUrl = new linkUrl();
	private ArrayList<Student> array_list = new ArrayList<Student>(); 

	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		super.onCreate();
		dropSpinner();
		Log.d("obj3", String.valueOf(array_list));
	}

	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		// TODO Auto-generated method stub
		return super.onStartCommand(intent, flags, startId);
	}
	
	public ArrayList<Student> dropSpinner() {
		contacts = JSONParser.getJsonarray(mLinkUrl.city);
		for (int i = 0; i < contacts.length(); i++) {
			try {
				Student student;
				student = new Student(contacts.getString(i));
				array_list.add(student);
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
		return array_list;
	}
}
